﻿using HPIT_Library_Modal;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace HPIT_Library
{
    public partial class updatePwd : BasePage
    {
        protected LoginInfo LoginInfoModel = new LoginInfo();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                LoginInfo loginInfo = Session["Info"] as LoginInfo;
                if (loginInfo != null)
                {
                    LoginInfoModel = loginInfo;
                }
                
                oldName.Text = Convert.ToString(LoginInfoModel.password);
                Label1.Text= Convert.ToString(LoginInfoModel.id);
            }
        }

        protected void BtnUpdatePwd_Click(object sender, EventArgs e)
        {
            var pwd = Convert.ToString(txtPwd.Text);
            var id = Convert.ToInt32(Label1.Text);
          var num=  HPIT_Library_BLL.LoginManger.UpdatePwd(pwd,id);
            if (num>0)
            {
                Response.Write("<script>alert('修改成功,将返回登录页面使用新密码登录');top.location.href='Library.aspx';</script>");
            }
            else
            {
                Response.Write("<script>alert('修改失败');</script>");
            }
        }

        //protected void BtnUpdatePwd_Click(object sender, EventArgs e)
        //{

        //}
    }
}